<?php
ob_start();

$orderId = $_GET['orderId'];
//echo 'jjjj'.$orderId;
//$orderId='82';

$host="localhost"; // Host name 
$username="hambaaco_app"; // Mysql username  
$password="sdfsiJdsf435jf"; // Mysql password 
$db_name="hambaaco_tshirts"; // Database name 

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// To protect MySQL injection (more detail about MySQL injection)
$orderId = stripslashes($orderId);
$orderId = mysql_real_escape_string($orderId);

$orders_sql="select nm_fname,nm_lname,tx_addr1,tx_addr2,tx_city,tx_state,cd_pincode,tx_email,tx_contact_no,DATE_FORMAT(dt_order,'%d %b %Y') as dt_order,tx_shipping_addr,st_order from orders where id_order=".$orderId;
$result_orders_sql=mysql_query($orders_sql);
$row_orders= mysql_fetch_array($result_orders_sql);

$order_details_sql="select nm_product,id_order,order_details.id_product,quantity,order_details.price from products, order_details where products.id_product =order_details.id_product and id_order=".$orderId;
$result_order_details_sql=mysql_query($order_details_sql);


$tx_shipping_addr = $row_orders['nm_fname'].' '.$row_orders['nm_lname'].'<br>'.$row_orders['tx_addr1'].'<br>'.$row_orders['tx_addr2'].'<br>'.$row_orders['tx_city'].'<br>'.$row_orders['tx_state'].' '.$row_orders['cd_pincode'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Merchandise :: Hambaa.com</title>
<link rel="stylesheet" type="text/css" href="styles/Graphitti_style.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="javascript/cart.js"></script>
<script type="text/javascript">
function submitform(){
	//alert('hi');
	var formId = document.getElementById('generatePdf');
	formId.action = 'order_summary_pdf.php';
	formId.submit();	

}
 $(document).ready(function(){
$("#retrieveOrderDetails").click(function(){	
var orderId=document.getElementById('orderId').value;
var email=document.getElementById('email').value;
alert(email);
alert(orderId);
//alert(qty);
$.ajax({url:"rest/data/getOrderDetails.php",
type:'GET',
data : {orderId:orderId,email:email},
success:function(result){
	alert(result);
		order = JSON.parse(result);
		alert(order.fname);
},
error:function(result){
	
}
});
});
});

</script>

<style>
		.black_overlay{
			display: none;
			position: fixed;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: black;
			z-index:1001;
			-moz-opacity: 0.8;
			opacity:.50;
			filter: alpha(opacity=80);
		}
		.white_content {
			display: none;
			position: fixed;
			top: 25%;
			left: 25%;
			width: 50%;
			height: 50%;
			padding: 16px;
			border: 16px solid orange;
			background-color: white;
			z-index:1002;
			overflow: auto;
		}
	</style>


</head>

<body>
<table id="containertable" cellpadding="0" cellspacing="0" border="0" width="950" align="center" >
<tr>
<td align="right">
	<div id="menulinks">
   
    <a href="index.php" class="active">Home</a>
    <a href="offers.php">Offers</a>
	<a href="about_us.php">About Us</a>
	<a href="contact_us.php">Contact Us</a>
    
    </div>

</td>
</tr>

</table>



<table  border="0" align="center" width="952" height="118" background="images/round_back1.png"  >
<tr >
<td width="121" height="114" align="right" valign="bottom">

<a href="index.php"><img src="images/logopng.png" width="103" height="99" /></a></td>
<td width="819" align="left" valign="top">
<a href="index.php"><img src="images/hambaa_logo_newjpg.jpg" width="308" height="107" /></a>
</td>

</tr>
</table>


<table id="hotitem_cart" border="0" width="950"  align="center" bgcolor="#FFFFFF" >
<tr>
<td width="8"></td>
<td width="356">
Order for your tshirt from our wide range.<br>
What's better, now you can create your own design! 
</td>
<td width="164"><img src="images/hot_items.png" width="164" height="61" /></td>
<td width="55">
        <img src="images/tshirts/ts1.jpg" height="55" width="55" />
</td>
        <td width="55">
        <img src="images/tshirts/ts2.jpg" height="55" width="55" />
        </td>
        <td width="55">
        <img src="images/tshirts/ts3.jpg" height="55" width="55" />
        </td>
         <td width="55">
        <img src="images/tshirts/ts4.jpg" height="55" width="55"  />
        </td>	

<td  align="right" width="150" >

<a href = "javascript:void(0)" class="cartbtn" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';getShoppingCart()"><table border="0" ><tr><td><img src="images/shopping_cart1.png" width="41" height="41" /></td>
<td>Cart(<span  id="order_count"></span>)</td></tr></table></a>

		<div id="light" class="white_content" >
        <div id="close_button" style="position:fixed;width:inherit;float:right" >
        <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"   ><img src="images/Close-button.png"  /></a></div>
        
 
 			<div id="table_container" style="overflow:auto" >
<!--            this is where the table is created -->
             
            </div>
           
            
 
        
        
        
        </div>

		<div id="fade" class="black_overlay" >
        
        </div>
</td>
</tr>

</table>


<table id="outertable" border="1" width="950" height="269" align="center" bgcolor="#FFFFFF" >

<tr >
<td  align="center" valign="top">
<div id="orderInquiry" >
<form id="trackOrder" method="GET"  >
Email: <input type="text" id="email" name="email" />
Orderid: <input type="text" id="orderId" name="orderId" />

</form>
<h3><a href="#" id="retrieveOrderDetails">submit</a></h3>
</div>
<div id="orderDetails" >
<h1>Order Details</h1>
    <table border="0" width="715" cellpadding="10">
    <tr>
    <td width="195" >Order No. : <?php echo $orderId ?></td>
    <td width="154" >Date : <?php echo $row_orders['dt_order'] ?></td>
    <td width="172" >Order status : </td>
    <td width="104" ><a href="#" onclick="submitform()"><span style="background-color:#0099CC;  padding:5px">Download pdf</span></a></td>
    </tr>
    </table>
   
    <table border="0">
	<tr valign="top"><td>
        <table border="0" width="481" cellpadding="0" align="left">
        <tr>
        <td colspan="2"><h4>Product</h4></td>
        <td width="85"><h4>Quantity</h4></td>
        <td width="86"><h4>Unit Price</h4></td>
        <td width="85"><h4>Sub Total</h4></td>
        </tr>
        <?php
        
        $grand_total=0;
        $total_quantity=0;
        while($row_order_details = mysql_fetch_array($result_order_details_sql))
        {
            $tx_id_order=$row_order_details['id_order'];
            $tx_id_product=$row_order_details['id_product'];
            $tx_nm_product=$row_order_details['nm_product'];
            $tx_quantity=$row_order_details['quantity'];
            $tx_price=$row_order_details['price'];
            $tx_sub_total=$row_order_details['quantity']*$row_order_details['price'];
            $grand_total+=$tx_sub_total;
            $total_quantity+=$tx_quantity;
        
            echo
                '<tr align="center">
                    <td width="60"><img  src="images/tshirts/ts'.$tx_id_product.'.jpg" height="60" width="60"></td>
                    <td>'.$tx_nm_product.'</td>
                    <td>'.$tx_quantity.'</td>
                    <td>'.$tx_price.'</td>
                    <td>'.$tx_sub_total.'</td>
                </tr>';
    
        }
    
        ?>
        <tr align="center">
        <td colspan="2"><h3>Grand Total</h3></td>
        <td width="85"><?php echo $total_quantity ?></td>
        <td width="86" align="right">Rs.</td>
        <td width="85"><h4><?php echo $grand_total ?> /-</h4></td>
        </tr>
        </table>
    </td>
    <td>
        <table border="0" cellpadding="0" width="207">
        <tr><td><h4>Shipping Address</h4></td></tr>
        <tr><td><?php echo $tx_shipping_addr ?></td></tr>
        <tr><td><h4>Delivered On</h4></td></tr>
        <tr><td><?php echo $row_orders['dt_order'] ?></td></tr>
        </table>
    </td>
    </tr>
    </table>

    
</div>    

</td>

<td width="200" valign="top">
	<table id="innerright" border="0" cellspacing="2"  width="200" align="right" background="images/tableback3.png" >
	<tr><td height="176"><h3>Recommended for you</h3></td></tr>
    <tr><td align="center" bgcolor="#FFFFFF" valign="middle">
    <a href = "mywishlist.php?timefilter=all" class="wishbtn" > My Wishlist</a><br><br>
    </td></tr>
    <tr><td bgcolor="#FF6666">
    <h6>We'd like to hear from you</h6>
    </td></tr>
	<tr align="center" ><td align="center"> 
    <h2><a href="suggest.php">Make your Suggestion</a></h2>
    </td></tr>
    </table>
</td>

</tr>
</table>

<table width="952" align="center" border="0" background="images/round_back2.png" height="58" >
<tr>
<td></td>
</tr>

</table>

<br>

<div id="footer" > 


<table border="0" width="952" height=154 align="center" >
<tr>
<td >
<h1>My Hambaa</h1>
</td>
<td >
<h1>Shopping Policies</h1>
</td>
<td >
<h1>Payment Information</h1>
</td>
<td >
<h1>Contact Us</h1>
</td>
</tr>

<tr>
<td>
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';getShoppingCart1()">My Cart</a> |
<a href="about_us.php">My Order</a> |
<a href="about_us.php">FAQs</a>
</td>

<td >
<a href="about_us.php">Return Policy</a> |
<a href="about_us.php">Refund Policy</a> |
<a href="about_us.php">Terms and Conditions</a>
</td>

<td >
<a href="about_us.php">Payment Options: </a>COD
</td>

<td >
e-mail:
<a href="mailto:care@hambaa.com">care@hambaa.com</a>
</td>
</tr>

<tr align="center"><td colspan="4">
<hr />

&copy;2012 All Rights Reserved by <a href="index.php">www.hambaa.com</a>
</td></tr>
</table>
</div>

<?php 
ob_end_flush();
?>


<form id="generatePdf" method="POST" target="_blank" >
<input type="hidden" id="pdfemail" name="pdfemail" />
<input type="hidden" id="pdforderid" name="pdforderid" />
</form>
</body>
</html>

